import {Directive, DirectiveBinding, ObjectDirective, VNode} from "@vue/runtime-core";

export interface LyricUpdateElBindValue {
  func: () => void;
  /**
   * 是否立即执行一次
   */
  immediate: boolean;
  time: number;
}

export const LyricUpdateEl: Directive = {
  mounted(el, binding: DirectiveBinding, vnode: VNode, prevVNode) {
    let bindValue: LyricUpdateElBindValue = binding.value
    if (bindValue.immediate) {
      bindValue.func()
    }
  },
  updated(el, binding: DirectiveBinding, vnode: VNode, prevVNode) {
    let bindValue: LyricUpdateElBindValue = binding.value
    bindValue.func()
  },
} as ObjectDirective
